package com.example.wuhexian.finger_guess;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;

import com.example.wuhexian.R;

public class JiaActivity extends AppCompatActivity implements View.OnClickListener {
    RadioGroup rg;
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jia);
        rg = findViewById(R.id.rg_finger);
        btn = findViewById(R.id.btn_finger);
        btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int checkedRadioButtonId = rg.getCheckedRadioButtonId();
        String msg = "石头";
        if (checkedRadioButtonId == R.id.rb1_finger) {
            msg = "石头";
        }else if (checkedRadioButtonId == R.id.rb2_finger){
            msg = "剪刀";
        }else if (checkedRadioButtonId == R.id.rb3_finger){
            msg = "布";
        }
        //传值
        Intent intent = new Intent();
        intent.setClass(this,YiActivity.class);
        intent.putExtra("jia",msg);
        startActivity(intent);
    }
}